#pragma once

#include <stdint.h>

#include "util/executor.h"

#include "asio.h"


class IOContext : public Executor
{
public:
    IOContext();

    virtual ~IOContext();

    asio::io_context &provider();

    void exec();

    void stop();

    virtual void post(std::function<void()> &&action) override;

    uint64_t nextComponentId() {
        return nextComponentId_++;
    }

private:
    asio::io_context ioc_;
    uint64_t nextComponentId_ = 1;
    bool stopped_ = false;
};
